package com.bw.zg3park2212.task

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.ToastUtils
import com.bw.base.entity.TaskEntityItem
import com.bw.base.mvvm.BaseActivity
import com.bw.zg3park2212.databinding.ActivityTaskBinding
import com.bw.zg3park2212.databinding.ActivityTaskXiangBinding
import com.bw.zg3park2212.task.TaskViewModel
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch

@AndroidEntryPoint
@Route(path = "/app/TaskXiangActivity")
class TaskXiangActivity : BaseActivity<ActivityTaskXiangBinding,TaskViewModel>() {
   @Autowired
   lateinit var task:TaskEntityItem
   lateinit var taskXiangAdpter: TaskXiangAdpter
    override fun intitView() {
        ARouter.getInstance().inject(this)
        viewmodel.gettaskxiang(task.id)
        taskXiangAdpter= TaskXiangAdpter()
        binding.rv.adapter=taskXiangAdpter
        binding.rv.layoutManager=LinearLayoutManager(this)
    }

    override fun intitData() {
        viewmodel.taskxiangSuccse.observe(this){
            binding.taskName.text=it.taskName
            binding.patrolTime.text=it.patrolTime
                it.patrolPoints.forEach {
                viewmodel.getpointxiang(it)
            }
        }
        viewmodel.pointxiangSuccse.observe(this){
            taskXiangAdpter.addData(it)
            taskXiangAdpter.notifyDataSetChanged()
        }
    }
}